package com.zzb.polymorphism;

import java.util.Scanner;

public class Boss {
    public static void main(String[] args) {

        //创建对象
        Scanner sc = new Scanner(System.in);
        Coder coder = new Coder();
        Animal a;

        //选择动物
        System.out.println("输入数字选择喂养的动物（1.猪  2.狗  3.猫）：");
        int choice = sc.nextInt();
        switch (choice) {
            case 1:
                a = new Pig();
                break;
            case 2:
                a = new Dog();
                break;
            case 3:
                a = new Cat();
                break;
            default:
                a = null;
                break;
        }

        //喂食
        if (a == null) {
            System.out.println("你没有这个动物");
        } else {
            coder.feeding(a);
        }
    }
}
